package com.threeti.jiayusms.domain.service.communicationmessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.jiayusms.domain.model.CommunicationMessage;
import com.threeti.jiayusms.framework.util.DynaSearchCriteria;
import com.threeti.jiayusms.framework.util.PagedListHandler;
import com.threeti.jiayusms.infrastructure.communicationmessage.CommunicationMessageDao;

@Service
@Transactional(readOnly=true)
public class CommunicationMessageQueryServiceImpl implements
		CommunicationMessageQueryService {

	@Autowired
	private CommunicationMessageDao dao;

	@Override
	public CommunicationMessage findCommunicationMessageBy(Long messageId) {
		return dao.loadBy(messageId, true);
	}

	@Override
	public CommunicationMessage findCommunicationMessageBy(String messageCustomId) {
		return dao.loadBy(messageCustomId);
	}

	@Override
	public PagedListHandler<CommunicationMessage> findAllMsgTemplatesByPage(int currentPageIndex, int startingIndex) {
    return dao.findAllMsgTemplatesByPage(currentPageIndex, startingIndex);
	}

	@Override
	public PagedListHandler<CommunicationMessage> findMsgTemplatesByPage(DynaSearchCriteria dynaSearchCriteria, int currentPageIndex, int startingIndex) {
		if (!dynaSearchCriteria.isAnyConditionInput()) {//无条件查询
			return dao.findAllMsgTemplatesByPage(currentPageIndex, startingIndex);
		}
    return dao.findMsgTemplatesByPage(dynaSearchCriteria, currentPageIndex, startingIndex);
	}
	
	
}
